home *** CD-ROM | disk | FTP | other *** search
/ LineOne ISP Sign-Up 5 / LineOne.iso / assets / cxt / scripts / parentScripts.cst / 00031_xtrasManager parent.ls < prev    next >
Encoding:
Text File  |  2001-01-27  |  3.3 KB  |  122 lines

  1. -- 2000.03.13
  2. -- Clive Green <clivegreen@atlas.co.uk>
  3.  
  4. ------------------------------------------------------------------------------------------------------
  5.  
  6. -- xtras setup and detection
  7.  
  8. ------------------------------------------------------------------------------------------------------
  9.  
  10. -- declare properties:
  11. property main          -- main code directory object
  12. property loadedXtras   -- a list of xtra names
  13. property requiredXtras -- a list of required scripting xtras
  14.  
  15. property fileIOxtra    -- lingo controller for fileIO functions
  16. property buddyAPIxtra  -- lingo controller for buddyAPI functions
  17.  
  18. ------------------------------------------------------------------------------------------------------
  19.  
  20. on new me,L
  21.   
  22.   -- (1) extract and check arguments:
  23.   
  24.   -- check for a parameter list:
  25.   if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"xtrasManager:new"]
  26.   
  27.   -- a reference to the parent codebase is REQUIRED:
  28.   main = L[#main]
  29.   if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"xtrasManager:new"]
  30.   
  31.   --------------------
  32.   
  33.   -- (2) compile a list of loaded xtra names:
  34.   loadedXtras = []
  35.   
  36.   xL = the xtraList
  37.   repeat with i in xL
  38.     
  39.     -- add the name of each xtra:
  40.     add loadedXtras,i[#name]
  41.     
  42.   end repeat
  43.   
  44.   --------------------
  45.   
  46.   -- get the data manager:
  47.   dm = main.getDataManager()
  48.   if (ilk(dm) <> #instance) then return dm
  49.   
  50.   --------------------
  51.   
  52.   -- (3) what scripting xtras are required for programme operation?
  53.   
  54.   -- a list of required xtras must be provided (even if its empty):
  55.   rxL = dm.getData([#set:#settings, #item:#requiredXtras])
  56.   if stringP(rxL[#error]) then return rxL
  57.   
  58.   requiredXtras = rxL
  59.   
  60.   -- xtra names/requirements can vary by platform!
  61.   um = main.getUtilityMethods()
  62.   p  = um.thePlatform()
  63.   xL = requiredXtras[p]
  64.   
  65.   -- ensure that ALL of these are currently available:
  66.   repeat with i = 1 to count(xL)
  67.     
  68.     -- pull ith xtra's label and name:
  69.     x = getPropAt(xL,i)
  70.     n = xL[i]
  71.     
  72.     -- fail on first xtra which turns up missing:
  73.     if not me.xtraFound(n) then return ┬¼
  74.     [#error:#requiredXtraMissing, #msg:"xtrasManager:new" && n]
  75.     
  76.     -- attempt to instance an object to manage this xtra:
  77.     o = main.createInstance(x,L)  
  78.     if (ilk(o) <> #instance) then return o
  79.     
  80.     -- store a named reference to the xtra controller o:
  81.     setaProp me,x,o
  82.     
  83.   end repeat
  84.   
  85.   --------------------
  86.   
  87.   -- pass back my address:
  88.   return me
  89.   
  90.   ----------------------------------------------------------------------------------------------------
  91.   
  92. on xtraFound me,n
  93.   
  94.   -- returns a boolean indicating whether an xtra starting with the string n is currently loaded:
  95.   
  96.   -- need a string to continue:
  97.   if not stringP(n) or n = "" then return 0
  98.   
  99.   -- recurse until xtra is found:
  100.   repeat with i in loadedXtras
  101.     
  102.     -- success:
  103.     if i starts n then return 1
  104.     
  105.   end repeat
  106.   
  107.   -- failure:
  108.   return 0
  109.   
  110.   ----------------------------------------------------------------------------------------------------
  111.   
  112. on getBuddyAPIxtra me
  113.   
  114.   return buddyAPIxtra
  115.   
  116.   ----------------------------------------------------------------------------------------------------
  117.   
  118. on getFileIOxtra me
  119.   
  120.   return fileIOxtra
  121.   
  122.   ----------------------------------------------------------------------------------------------------